<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/template/template_layout_lr.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
.ui-button, .ui-button span, button.ui-button.ui-state-default span,
	.ui-button.ui-state-default span {
	font-weight: normal
}
</style>
		<script type="text/javascript">
			function start() {
				PF('statusDialog').show();
			}

			function stop() {
				PF('statusDialog').hide();
			}
		</script>
	</ui:define>
	<ui:define name="left-box-title">
	线路选择树
	</ui:define>
	<ui:define name="left-box-body">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div class="box-header with-border" id="searchInput">
			<h:form id="form1">
				<p:growl id="msgs" showDetail="true" />
				<p:autoComplete placeholder="输入拼音首字母可查" id="line_id" size="20"
					value="#{lineTowerConfigController.filterAcLineSegment}"
					completeMethod="#{cimUtilController.completeLineSegment}"
					scrollHeight="400" style="float:left;">
					<p:ajax update="line_id :treeForm:tree" event="itemSelect"
						listener="#{lineTowerConfigController.autoCompleteAcLineSegment}" />
				</p:autoComplete>
				<p:commandButton icon="fa fa-refresh"
					style="margin-left:3px;height:30px;"
					update="line_id :treeForm:tree"
					actionListener="#{lineTowerConfigController.init()}" />
			</h:form>
		</div>
		<div class="box-body  with-border">
			<h:form id="treeForm">
				<p:tree value="#{lineTowerConfigController.treeNodeResource}"
					style="width:400px;border:none" selectionMode="single" var="node"
					dynamic="true" id="tree" widgetVar="tree" animate="true">
					<p:ajax event="select" process="@this"
						update=":rightForm:towerInfos :rightForm"
						listener="#{lineTowerConfigController.onNodeSelect}" />
					<p:treeNode type="type" icon="fa fa-home">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<p:treeNode type="voltage" icon="fa fa-home">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<p:treeNode type="ACLineSegment" icon="fa fa-home">
						<h:outputText value="#{node}" />
					</p:treeNode>
					<p:treeNode type="DcLinesegment" icon="fa fa-home">
						<h:outputText value="#{node}" />
					</p:treeNode>
				</p:tree>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="right-box-title">
	杆塔详细信息
	</ui:define>
	<ui:define name="right-box-body">
		<div class="box-body  with-border">
			<h:form id="rightForm">
				<p:toolbar id="tools">
					<f:facet name="left">
						<p:commandButton value="新建杆塔" icon="ui-icon-plus"
							rendered="#{s:hasPermission(session,'xtsz_dwmx_gtxxwh_xjgt')}"
							disabled="#{lineTowerConfigController.currentSelect == null or (lineTowerConfigController.currentSelect.type != 'ACLineSegment' and lineTowerConfigController.currentSelect.type != 'DcLinesegment')}"
							update=":createForm:createDetail :createForm:createSaveBtn rightForm:towerInfos"
							actionListener="#{lineTowerConfigController.preCreate()}"
							oncomplete="PF('createDlg').show()" />
						<p:commandButton
							update=":editForm:editDetail rightForm:towerInfos " value="编辑杆塔"
							oncomplete="PF('editDlg').show()" icon="ui-icon-pencil"
							title="编辑"
							disabled="#{lineTowerConfigController.currentSelect == null or (lineTowerConfigController.currentSelect.type != 'ACLineSegment' and lineTowerConfigController.currentSelect.type != 'DcLinesegment') or (lineTowerConfigController.selectedTowers.size() != 1)}"
							rendered="#{s:hasPermission(session,'jcsj_sjwh_xlgtwh_bjgt')}"
							actionListener="#{lineTowerConfigController.preEdit()}">
						</p:commandButton>
						<p:commandButton id="deleteTowerBtn"
							update="rightForm:towerInfos rightForm:tools :form1:msgs"
							icon="ui-icon-trash" title="删除" value="删除杆塔"
							actionListener="#{lineTowerConfigController.delete()}"
							disabled="#{lineTowerConfigController.currentSelect == null or (lineTowerConfigController.currentSelect.type != 'ACLineSegment' and lineTowerConfigController.currentSelect.type != 'DcLinesegment') or (lineTowerConfigController.selectedTowers.size() lt 1)}"
							rendered="#{s:hasPermission(session,'jcsj_sjwh_xlgtwh_scgt')}">
							<p:confirm header="提示" icon="ui-icon-alert"
								message="如杆塔未全部删除，则线路起止站不会被删除，确定删除所选杆塔数据?" />
						</p:commandButton>
						<p:commandButton value="下载模板" ajax="false"
							icon="ui-icon-arrowthick-1-s"
							actionListener="#{lineTowerConfigController.fileDownloadView()}">
							<p:fileDownload value="#{lineTowerConfigController.file}" />
						</p:commandButton>
						<p:commandButton id="newStatBtn" value="上传杆塔信息"
							actionListener="#{lineTowerConfigController.initLoopLineName()}"
							update=":formUpload:loopLineNameId"
							rendered="#{s:hasPermission(session,'jcsj_sjwh_ycsbwh_xlgtwh_scgtxx')}"
							disabled="#{lineTowerConfigController.currentSelect == null or (lineTowerConfigController.currentSelect.type != 'ACLineSegment' and lineTowerConfigController.currentSelect.type != 'DcLinesegment')}"
							onclick="PF('fileUploadDialog').show()">
							<p:confirm header="提示" message="该操作会首先删除该条线路原有的杆塔信息，确定继续上传吗?"
								icon="ui-icon-alert" />
						</p:commandButton>
						<p:commandButton id="clearMapCacheBtn" value="更新地图缓存"
							update=":form1:msgs"
							rendered="#{s:hasPermission(session,'jcsj_sjwh_ycsbwh_xlgtwh_gxdthc')}"
							actionListener="#{lineTowerConfigController.clearMapCache()}" />
						<p:commandButton icon="ui-icon-arrowthick-1-s" value="导出线路杆塔" 
						rendered="#{s:hasPermission(session,'jcsj_sjwh_ycsbwh_xlgtwh_dcxlgt')}"
							disabled="#{lineTowerConfigController.currentSelect == null or (lineTowerConfigController.currentSelect.type != 'ACLineSegment' and lineTowerConfigController.currentSelect.type != 'DcLinesegment')}"
							actionListener="#{lineTowerConfigController.exportLineTower()}"
							ajax="false">
							<p:fileDownload value="#{lineTowerConfigController.file}" />
						</p:commandButton>
					</f:facet>
				</p:toolbar>
				<p:dataTable id="towerInfos" var="towerInfo"
					rowKey="#{towerInfo.id}"
					value="#{lineTowerConfigController.lineTowers}"
					selection="#{lineTowerConfigController.selectedTowers}" rows="20"
					paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="20,50,100" emptyMessage="无杆塔信息">
					<f:facet name="{Customization}">
						<p:outputLabel
							value="总计：#{lineTowerConfigController.lineTowers.size()} 条记录"
							style="margin-right:20px;" />
					</f:facet>
					<p:ajax event="rowUnselectCheckbox" update="rightForm:tools" />
					<p:ajax event="rowSelectCheckbox" update="rightForm:tools"
						listener="#{lineTowerConfigController.onTowerSelect}" />
					<p:ajax event="rowSelect" update="rightForm:tools"
						listener="#{lineTowerConfigController.onTowerSelect}" />
					<p:column selectionMode="multiple" width="40"
						style="text-align:center" />
					<p:column headerText="序号" width="5%">
       					<h:outputText value="#{towerInfo.serialno}" />
					</p:column>
					<p:column headerText="杆塔号" width="8%" style="text-align:center">
						<h:outputText
							value="#{lineTowerConfigController.showTowerNo(towerInfo)}" />
					   	</p:column>
					   <p:column headerText="线段编号" width="12%">
					        <h:outputText value="#{towerInfo.lineno}" />
					    </p:column>
					    <p:column headerText="经度" width="12%">
					        <h:outputText value="#{towerInfo.longitude}" />
					    </p:column>
					    <p:column headerText="纬度" width="12%">
					        <h:outputText value="#{towerInfo.latitude}" />
					    </p:column>
					    <p:column headerText="所属线路" width="12%">
					        <h:outputText value="#{towerInfo.lineName}" />
					    </p:column>
					 	<p:column headerText="线路电压" width="7%">
					        <h:outputText value="#{towerInfo.lineVoltage}" />
					    </p:column>
					<p:column headerText="距离起始变电站(米)" width="13%">
						<h:outputText value="#{towerInfo.distanceFromStartStation}" />
					    </p:column>
					<p:column headerText="距离上一杆塔(米)" width="12%">
						<h:outputText value="#{towerInfo.distanceFromLastTower}" />
					    </p:column>
					<p:column headerText="是否显示" width="7%">
					       	<h:outputText value="隐藏"
							rendered="#{towerInfo.isShowInMap==0}" />
						<h:outputText value="显示" rendered="#{towerInfo.isShowInMap==1}" />
					    </p:column>
				</p:dataTable>
			</h:form>
			<h:form id="editForm">
				<p:dialog widgetVar="editDlg" header="杆塔编辑" modal="true"
					id="editDlg" width="600" height="300">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton id="editSaveBtn" value="保存" icon="ui-icon-disk"
								update=":rightForm:towerInfos :form1:msgs"
								oncomplete="PF('editDlg').hide()"
								actionListener="#{lineTowerConfigController.saveEdit()}" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel id="editDetail">
						<p:panelGrid
							rendered="#{not empty lineTowerConfigController.selected}">
							<p:row>
								<p:column>
									<h:outputLabel>所属线路</h:outputLabel>
								</p:column>
								<p:column>
									<h:outputText style="width:100%"
										value="#{lineTowerConfigController.selected.lineName}" />
								</p:column>
								<p:column>
									<h:outputLabel>线路电压</h:outputLabel>
								</p:column>
								<p:column>
									<h:outputText style="width:100%"
										value="#{lineTowerConfigController.selected.lineVoltage}" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>是否同杆</h:outputLabel>
								</p:column>
								<p:column>
									<h:outputText
										value="#{lineTowerConfigController.selected.isLoop == 0?'否':'是'}" />
								</p:column>
								<p:column>
									<h:outputLabel>同杆线路</h:outputLabel>
								</p:column>
								<p:column>
									<h:outputText
										value="#{lineTowerConfigController.selected.loopCimName}" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>线段编号</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.selected.lineno}"></p:inputText>
								</p:column>
								<p:column>
									<h:outputLabel>是否显示</h:outputLabel>
								</p:column>
								<p:column>
									<p:selectOneMenu style="width:100%"
										value="#{lineTowerConfigController.selected.isShowInMap}">
											            <f:selectItem itemLabel="显示" itemValue="1" />
											            <f:selectItem itemLabel="隐藏" itemValue="0" />
						       				  		</p:selectOneMenu>
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>序号</h:outputLabel>
								</p:column>
								<p:column>
									<h:outputText
										value="#{lineTowerConfigController.selected.serialno}" />
								</p:column>
								<p:column>
									<h:outputLabel>杆塔号</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.selected.towerno}"></p:inputText>
								</p:column>

							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>经度</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.selected.longitude}"></p:inputText>
								</p:column>
								<p:column>
									<h:outputLabel>纬度</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.selected.latitude}"></p:inputText>
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
			</h:form>
			<h:form id="formUpload">
				<p:dialog header="上传文件" widgetVar="fileUploadDialog" modal="true"
					id="fileUploadDialog" width="700" height="400">
					<h4 style="color: red">1、必须保证上传文件中的某列数据全部为空或全部非空！</h4>
					<h4 style="color: red">2、当线路编号不为空时，线路编号顺序号也不能为空！</h4>
					<h4 style="color: red">3、当杆塔顺序号为空时，必须保证杆塔名称仅含有_、-、+这三种特殊字符！</h4>
					<p:outputLabel value="如有回路，请选择：" />
					<p:autoComplete placeholder="输入首字母可查" id="loopLineNameId"
						value="#{lineTowerConfigController.loopLineName}"
						completeMethod="#{lineTowerConfigController.completeLineName}"
						dropdown="true" scrollHeight="300">
						<p:ajax event="itemSelect"
							listener="#{lineTowerConfigController.getSelectLoopLineName}"></p:ajax>
					</p:autoComplete>
					<p:fileUpload style="margin-top:10px" cancelLabel="取消"
						oncomplete="PF('fileUploadDialog').hide()"
						fileUploadListener="#{lineTowerConfigController.handleFileUpload}"
						update=":rightForm:towerInfos :form1:msgs" uploadLabel="上传"
						label="文件" />
				</p:dialog>
			</h:form>
			<h:form id="createForm">
				<p:dialog widgetVar="createDlg" header="新建杆塔" modal="true"
					id="createDlg" width="610" height="450">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton id="createSaveBtn" value="保存"
								icon="ui-icon-disk" update=":rightForm:towerInfos :form1:msgs"
								oncomplete="PF('createDlg').hide()"
								actionListener="#{lineTowerConfigController.saveNew}" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel id="createDetail">
						<p:panelGrid
							rendered="#{not empty lineTowerConfigController.lineTower}">
							<p:row>
								<p:column>
									<h:outputLabel>所属线路</h:outputLabel>
								</p:column>
								<p:column>
									<h:outputText
										value="#{lineTowerConfigController.lineTower.lineName}" />
								</p:column>
								<p:column>
									<h:outputLabel>线路电压</h:outputLabel>
								</p:column>
								<p:column>
									<h:outputText
										value="#{lineTowerConfigController.lineTower.lineVoltage}" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>线段编号</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.lineTower.lineno}" />
								</p:column>
								<p:column>
									<h:outputLabel>是否显示</h:outputLabel>
								</p:column>
								<p:column>
									<p:selectOneMenu style="width:100%"
										value="#{lineTowerConfigController.lineTower.isShowInMap}">
											            <f:selectItem itemLabel="显示" itemValue="1" />
											            <f:selectItem itemLabel="隐藏" itemValue="0" />
						       				  		</p:selectOneMenu>
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>序号</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText value="#{lineTowerConfigController.serialNo}"
										required="true" requiredMessage="序号为必填项目" />
								</p:column>
								<p:column>
									<h:outputLabel>杆塔号</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.lineTower.towerno}" />
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>经度</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.lineTower.longitude}" />
								</p:column>
								<p:column>
									<h:outputLabel>纬度</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.lineTower.latitude}" />
								</p:column>
							</p:row>
							<p:row>
								<p:column colspan="4">
									<h:outputLabel>如果是同杆塔，请填写以下信息：</h:outputLabel>
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>是否同杆</h:outputLabel>
								</p:column>
								<p:column>
									<p:selectOneMenu style="width:100%"
										value="#{lineTowerConfigController.lineTower.isLoop}">
											            <f:selectItem itemLabel="否" itemValue="0" />
											            <f:selectItem itemLabel="是" itemValue="1" />
						       				  		</p:selectOneMenu>
								</p:column>
								<p:column>
									<h:outputLabel>同杆线路</h:outputLabel>
								</p:column>
								<p:column>
									<p:autoComplete placeholder="输入首字母可查"
										value="#{lineTowerConfigController.lineTower.loopCimName}"
										completeMethod="#{lineTowerConfigController.completeLineName}"
										dropdown="true" scrollHeight="300">
										<p:ajax event="itemSelect" update="loopLineSelno"
											listener="#{lineTowerConfigController.getSelectLoopLineName}"></p:ajax>
									</p:autoComplete>
								</p:column>
							</p:row>
							<p:row>
								<p:column>
									<h:outputLabel>序号</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText id="loopLineSelno"
										value="#{lineTowerConfigController.loopSerialNo}"
										required="true" requiredMessage="序号为必填项目" />
								</p:column>
								<p:column>
									<h:outputLabel>线段编号</h:outputLabel>
								</p:column>
								<p:column>
									<p:inputText style="width:100%"
										value="#{lineTowerConfigController.loopLineno}"></p:inputText>
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
	</ui:define>
</ui:composition>